<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

</body>
</html><!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Title</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1.0, user-scalable=no"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <meta name="renderer" content="webkit">
    <link rel="stylesheet" href="../mdui/css/mdui.min.css">
    <script defer src="../mdui/js/mdui.min.js"></script>
    <script src="../js/axios.min.js"></script>
    <script src="../js/qs.min.js"></script>
    <script src="../js/common.js"></script>
    <script src="../js/vue.js"></script>

</head>
<body class="mdui-theme-primary-indigo mdui-theme-accent-green">
<div class="mdui-container-fluid" id="app">
    <h1 class="mdui-text-color-theme">部门列表</h1>
    <div style="margin-bottom: 8px;">
        姓名: <input v-model="name" type="text" placeholder="请输入部门名">
        <button @click="findRooms(name)" class="mdui-btn mdui-btn-raised mdui-ripple mdui-color-blue-700">查询</button>
        <!--        <button @click="reset" class="mdui-btn mdui-btn-raised mdui-ripple mdui-color-blue-700">重置</button>-->
    </div>

    <div style="margin-bottom: 9px;">
        <a href="add.html
    " class="mdui-btn mdui-btn-raised mdui-ripple mdui-color-theme-accent">添加新部门</a>
    </div>
    <table class="mdui-table mdui-table-hoverable">
        <thead>
        <tr>
            <th>编号</th>
            <th>部门名称</th>
            <th>部门描述</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        <tr v-for="(d,index) in departments">
            <td>{{d.id}}</td>
            <td>{{d.dname }}</td>
            <td>{{d.descr}}</td>
            <td>
                <a :href="'edit.html?id='+d.id"
                   class="mdui-btn mdui-btn-icon mdui-color-theme-accent mdui-ripple">
                    <i class="mdui-icon material-icons">edit</i>
                </a>
                <button @click="deleteUser(r.id,index)"
                        class="mdui-btn mdui-btn-icon mdui-color-theme-accent mdui-ripple">
                    <i class="mdui-icon material-icons">delete</i>
                </button>
            </td>
        </tr>
        </tbody>
    </table>


</div>

<script>
    let vm = new Vue({
        el: "#app",
        data: {
            departments: [],
            name: '',
        },
        created() {
            this.findList();
        },
        filters: {},

        methods: {
            findList() {
                let _this = this
                axios.get("/depaerment/list")
                    .then(function (res) {
                        _this.departments = res.data;
                    })
            },
            // findRooms() {
            //     let _this = this
            //     // alert(this.name)
            //     axios.get("/meetingroom/findByname", {
            //         params: {
            //             name: this.name
            //         }
            //     })
            //         .then(function (res) {
            //             _this.rooms = res.data
            //         })
            //
            // },
            // deleteUser(rid, index) //uid传到后台后台正确删除后 根据index移除数组中对应的数据
            // {
            //     let _this = this;
            //     axios.delete("/meetingroom/deleteRoom/" + rid)
            //         .then(function (res) {
            //             if (res.data.success) {
            //                 _this.rooms.splice(index, 1)
            //                 mdui.alert("删除成功");
            //             }
            //
            //         })
            //
            // },
        }
    });
</script>


</body>
</html>